/**
 *
 */
package com.example.demo2.utils;


import com.example.demo2.enums.ResponseCode;
import com.example.demo2.resvo.ResponseVO;
import lombok.experimental.UtilityClass;

/**
 * @ClassName: ResponseUtils

 * @author thomas
 * @date Oct 9, 2019 4:06:03 PM
 *
 */
@UtilityClass
public class ResponseUtils {

    /**
     * default return success
     * @param data
     * @return
     */
    public static<T> ResponseVO<T> buildResponseVO(T data) {
        return new ResponseVO<>(
                ResponseCode.RESPONSE_RETURN_CODE_SUCCESS.getCode(),
                ResponseCode.RESPONSE_RETURN_CODE_SUCCESS.getMessage(), data);
    }

    public static<T> ResponseVO<T> buildResponseVO(ResponseCode userResponseCode, T data) {
        return new ResponseVO<>(userResponseCode.getCode(), userResponseCode.getMessage(), data);
    }

    public static<T> ResponseVO<T> buildResponseVO(String code, String message, T data) {
        return new ResponseVO<>(code, message, data);
    }

}
